import BaseEntity from '../../BaseEntity'

export default class Collection<T> extends BaseEntity<T> {
    public url = this.options.baseURL + 'api/v1/collections'

    constructor(data?: T) {
        super(data!)
    }

    async getCollectionsDetails(collectionId: string) {
        return await this.getInstance()
            .get(`${this.url}/${collectionId}/details`)
            .then(res => {
                return res.data
            })
    }

    async getCollections(p: number = 0, n: number = 9) {
        return await this.getInstance()
            .get(`${this.url}?p=${p}&n=${n}`)
            .then(res => {
                return res.data
            })
    }

    async getGoodsById(collectionId: string, p: number = 2, n: number = 10) {
        return await this.getInstance()
            .get(`${this.url}/${collectionId}/goods?p=${p}&n=${n}`)
            .then(res => {
                return res.data
            })
    }
}
